<?php
class Core {
//Things that need to be declared BEFORE everything else
function __construct(){

$this->selfname= end(explode("/", __FILE__));
$this->selfmd5 = md5_file("funk/core/".$this->selfname);

require_once("funk/funks/libraries/uri.php");
$this->uri = new uri();
require_once("funk/core/loader.php");
$this->load = new loader();

}


//General framework functions here
public function start()
{
require_once("funk/config/main.php");
if($this->uri->get_segment(1) != "" and file_exists("funk/pages/".$this->uri->get_segment(1).".php")){ // if there is a page after the root it will do...
include("funk/pages/". $this->uri->get_segment(1).".php"); //this stuff
$var = $this->uri->get_segment(2);
if ($var != ""){
$home1= $this->uri->get_segment(1);
$Index= new $home1();
//$Index->SetItUp();
//echo $test;
if($ob and $oc){
ob_start('ob_gzhandler');
}elseif($ob){
ob_start();
}elseif($oc){
ob_start('ob_gzhandler');
}
if($header){
include("funk/pages/other/header.php");
}
$Index->$var();
if($footer){
include("funk/pages/other/footer.php");
}
if($ob or $oc){
ob_end_flush();
			}
			
			
			
}else{ // if there is no extra function on URL
$home1= $this->uri->get_segment(1);
//$Index = new $home1();
//$Index->SetItUp();
echo $test;
if($ob and $oc){
ob_start('ob_gzhandler');
}elseif($ob){
ob_start();
}elseif($oc){
ob_start('ob_gzhandler');
}
if($header){
include("funk/pages/other/header.php");
}
$Index->index();
if($footer){
include("funk/pages/other/footer.php");
}
if($ob or $oc){
ob_end_flush();
			}
}


}elseif($this->uri->get_segment(1) and ! file_exists("funk/pages/".$this->uri->get_segment(1).".php")){ //if there is an extra segment but does not exist do a 404 error (Make custom option) 
if($ob and $oc){
ob_start('ob_gzhandler');
}elseif($ob){
ob_start();
}elseif($oc){
ob_start('ob_gzhandler');
}
if($header){
include("funk/pages/other/header.php");
}
if($cust_404){
include("funk/pages/other/404.php");
}
if($footer){
include("funk/pages/other/footer.php");
}
if($ob or $oc){
ob_end_flush();
			}

}else{// or just do the normal home page
include("funk/pages/".$home.".php");
$Index = new $home();
//$Index->SetItUp();
//echo $test;
if($ob and $oc){
ob_start('ob_gzhandler');
}elseif($ob){
ob_start();
}elseif($oc){
ob_start('ob_gzhandler');
}
if($header){
include("funk/pages/other/header.php");
}

$Index->index();
if($footer){
include("funk/pages/other/footer.php");
}
if($ob or $oc){
ob_end_flush();
			}
		}
	}
}
?>